<template>
    <div class="container">
        <div class="flex-container">
            <div class="flex-item">
                <el-select v-model="options.mode" placeholder="类型选择">
                    <el-option v-for="item in options.modeItems" :key="item.sign" :label="item.name" :value="item.sign" />
                </el-select>
            </div>
        </div>
        <el-table v-loading="dataset.loading" :data="dataset.items" class="el-mb-15" stripe>
            <!-- <el-table-column prop="oda.mediaTitle" label="视频标题" />
            <el-table-column fixed="right" label="操作">
                <template slot-scope="scope">
                    <el-button
                        @click.native.prevent="eventOnButtonOperate('videoDetails', scope.$index)"
                        type="text" size="small"
                    >视频详情</el-button>
                </template>
            </el-table-column> -->
        </el-table>
        <el-pagination
            @size-change="eventUpdateRequestLimit" @current-change="controllerRequestListDataset"
            :current-page="dataset.page" :page-size="dataset.limit" :total="dataset.total"
            :page-sizes="[10, 50, 100, 200, 300]"
            layout="total, sizes, prev, pager, next, jumper"
        />
        <el-drawer :visible.sync="drawer.show" direction="ltr" size="60%">
        </el-drawer>
    </div>
</template>

<script>
    import {
        Table, TableColumn, Pagination,
        Button, Select, Option,
        Drawer, Dialog,
        MessageBox, Message
    } from 'element-ui';

    export default {
        components: {
            [Table.name]: Table, [TableColumn.name]: TableColumn, [Pagination.name]: Pagination,
            [Button.name]: Button, [Select.name]: Select, [Option.name]: Option,
            [Drawer.name]: Drawer, [Dialog.name]: Dialog,
        },
        data () {
            return {
                options: {
                    mode: 0,
                    modeItems: [
                        {
                            name: '待收取', sign: 0
                        },
                        {
                            name: '待确认', sign: 1
                        },
                        {
                            name: '已完成', sign: 2
                        },
                        {
                            name: '已取消', sign: 3
                        }
                    ]
                },
                dataset: {
                    loading: false,
                    total: 0, limit: 10, page: 1,
                    items: []
                },
                drawer: {
                    show: false, handle: ''
                }
            }
        },
        mounted () {
            this.controllerRequestListDataset();
        },
        methods: {
            controllerRequestListDataset(page) {
                if(this.dataset.loading) return; else this.dataset.loading = true;
                if(page) this.dataset.page = page;

                var url = '',
                    params = {
                        page: this.dataset.page, limit: this.dataset.limit
                    };

                this.$util.postRequestInterface(url, params, {
                    success: (res) => {
                        this.dataset.total = res.count;
                        this.dataset.items = res.data;
                    },
                    complete: (e) => {
                        this.dataset.loading = false;
                    }
                });
            },
            eventUpdateRequestLimit(limit) {
                if(this.dataset.loading) return;

                this.dataset.limit = limit;
                this.dataset.page = 1;
                this.dataset.total = 0;
                
                this.controllerRequestListDataset();
            },
            eventOnButtonOperate(mode, index) {
                this.drawer.handle = mode;

                switch(mode) {
                    case 'details':
                        break;
                }
            }
        },
        watch: {
            'options.mode'(nVal, oVal) {
                this.options.mode = nVal;

                this.controllerRequestListDataset();
            }
        }
    }
</script>

<style lang="scss" scoped>
    .select-width {
        width: 30vw;
    }
</style>
